new Vue({
  el: '#app',
  data() {
    return {
      form: {
        page: 1,			//页数
        limit: 10,			//每页数据条数
        Enterprise_Info_SerialNumber:$.cookie('enterprise')
      },
      tableData: [],		//表格数据
      total: 1,
    }
  },
  mounted() {
    this.getList(this.form)
  },
  methods: {
    onSerach() {				//查询方法
      console.log("搜搜")
    },
    addContract() {
      console.log("跳转")
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    getList(data) {     //换页方法
      let _this = this
      $.ajax({
        type: 'POST',
        url: DomainName + "/getShareConfigAll?token=" + $.cookie('token'),
        data,
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href =  absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (Result) {
          _this.tableData = Result.tableData      //将获取的数据存到表格数据中
          _this.total = Number(Result.limit)
        },
        dataType: "json"
      });
    },
    expandChange(row) {
      $.ajax({
        type: 'POST',
        data: {
          Member_Share_Config_SerialNumber: row.Member_Share_Config_SerialNumber
        },
        url: DomainName + '/getShareConfigArticle?token=' + $.cookie("token"),
        success: function (res) {
          console.log(res);
          row.Children.member_share_config_article = res.Data;
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },
    Add() {
      window.location.href = './Add.html'
    },
    Delete(Member_Share_Config_SerialNumber){
      this.$confirm('此操作将作废次方案, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.delete(Member_Share_Config_SerialNumber);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消作废'
        });
      });
    },
    delete(Primary_Key){
      const _this = this
      $.ajax({
        url: DomainName + '/DeleteAction?token='+$.cookie('token'),
        type: 'POST',
        data: {
          TableName:'member_share_config',
          Primary_Key,
          Primary_Key_Name:'Member_Share_Config_SerialNumber',
        },
        success: function (res) {
          if(res.Status=='success'){
            _this.$message({
              type: 'success',
              message: '作废成功!'
            });
            _this.getList(_this.form);
          }
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        }
      })
    },
    Delete2(row){
      this.$confirm('此操作将作废次方案, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.delete2(row);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消作废'
        });
      });
    },
    delete2(row){
      const _this = this
      $.ajax({
        url: DomainName + '/DeleteAction?token='+$.cookie('token'),
        type: 'POST',
        data: {
          TableName:'member_share_config_article',
          Primary_Key:row.Member_Share_Config_Article_SerialNumber,
          Primary_Key_Name:'Member_Share_Config_Article_SerialNumber',
        },
        success: function (res) {
          if(res.Status=='success'){
            _this.$message({
              type: 'success',
              message: '作废成功!'
            });
            _this.expandChange(row);
          }
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        }
      })
    },
    showMember(EnterpriseInfo_SerialNumber) {
      sessionStorage.setItem("EnterpriseInfo_SerialNumber", EnterpriseInfo_SerialNumber)
      window.location.href = './show.html?EnterpriseInfo_SerialNumber=' + EnterpriseInfo_SerialNumber
    }
  },
})